package com.tommy.ddp.disposeHandler
{
	import com.tommy.ddp.GridDataManager;
	import com.tommy.ddp.MainManager;
	import com.tommy.ddp.box.BoxFactory;
	import com.tommy.ddp.box.DdpBox;
	import com.tommy.ddp.definition.BoxExeType;
	import com.tommy.ddp.manager.DisposeBoxManager;
	
	import org.taomee.component.containers.Box;

	/**
	 * 炸周围9个格子后，克隆出一个小的再炸一次
	 * @author hongxuan
	 * 
	 */	
	public class BoomDisposeHandler implements IDisposeHandler
	{
		public function BoomDisposeHandler()
		{
		}
		
		public function dispose(box:DdpBox):Vector.<DdpBox>
		{
			box.dispose();
			GridDataManager.removeBox(box);
			//return new Vector.<DdpBox>();
			var xS:int = box.column - 1;
			var xE:int = box.column + 1;
			
			var yS:int = box.row - 1;
			var yE:int = box.row + 1;
			
			//
			
			var vect:Vector.<DdpBox> = new Vector.<DdpBox>();
			for(var i:int = xS;i<=xE;i++)
			{
				for(var j:int = yS;j<=yE;j++)
				{
					var b:DdpBox = GridDataManager.getBox(i,j);
					if(b && !b.isInDisposeList)
						//DisposeBoxManager.addDisposeBox(b);
						vect.push(b);
				}
			}
			
			var newBox:DdpBox = BoxFactory.createSpecifiedBox(box.column,box.row,box.colorType,BoxExeType.BOOM_CLONE);
			newBox.isInDisposeList = true;
			MainManager.game.container.addChild(newBox);
			DisposeBoxManager.addBoomClone(newBox);
			//
			return vect;
		}
	}
}